package com.es.gateway.一砂云.sdk;

import com.es.gateway.sdk.ESGateway;
import com.es.gateway.sdk.app.comm.EsBalanceRequest;
import com.es.gateway.sdk.app.comm.EsBalanceResponse;
import com.es.gateway.sdk.constant.AlgorithmE;
import com.es.gateway.sdk.entity.GatewayResponse;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

@Slf4j
public class ESGatewayTester {

    /**
     * 测试网网关发送数据
     */
    @Test
    public void sendToGateWayTest() {
        String appCode = "d2808c1338ce01f3e3efdb486f9effb9";
        AlgorithmE algo = AlgorithmE.MD5;
        String key = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhdQdw6uTGz+X4e+/eGpu4dcKrfrjQAe0tTQyn6TuKBobcsUsESkx9jcCeG4cpuxmN8jNeDAZsbTujNLD/aYl2g==";
        ESGateway esGateway = new ESGateway(appCode, algo, key);

        // 调用通用接口查询余额,文档: https://esandinfo.yuque.com/yv6e1k/aa4qsg/la1w7otq7vg00i1g
        GatewayResponse gatewayResponse = esGateway.sendToGateWay(EsBalanceRequest.act, new EsBalanceRequest().toJsonStr());
        log.info("服务器端返回: {}", gatewayResponse.toJsonStr());
        if (gatewayResponse.getBizContent() != null) {
            EsBalanceResponse esBalanceResponse = EsBalanceResponse.fromJsonStr(gatewayResponse.getBizContent());
            log.info("业务数据为: {}", esBalanceResponse.toJsonStr());
        }
    }
}
